package dao;

import com.mls.guardian.config.helper.ConfigPathManagr;
import com.mls.guardian.config.helper.PropConfigHelper;
import com.mongodb.Mongo;

import java.util.Properties;

/**
 * Created by Lykos on 15/11/13.
 */
public class MongoFactory {
    private static Mongo mg = null;
    private MongoFactory(){
    }
    public static Mongo getInstance() throws Exception {
        if(mg == null){
            PropConfigHelper propConfigHelper = new PropConfigHelper();
            Properties properties = (Properties) propConfigHelper.parse(ConfigPathManagr.getConfigPath());
            mg = new Mongo(properties.getProperty("mongodb.ip"),Integer.parseInt(properties.getProperty("mongodb.port")));
        }
        return mg;
    }
    public static void destoryInstance(){
        mg = null;
    }

}
